import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

import Layout from '@/layout'
import Sidebar from '@/layout/Sidebar'

import Login from '@/views/login'
// 超管
import schoolBoardUser from '@/views/admin/schoolBoardUser'
import schoolUser from '@/views/admin/schoolUser'
import schoolBoard from '@/views/admin/schoolBoard'
import loginLog from '@/views/admin/loginLog'

Vue.use(VueRouter)

export const constRoutes = [{
    path: '/login',
    component: Login,
}];

// modulesName 控制模块，roles控制单个路由 
export const asyncRoutes = [
    // 超管端
    {
        path: '/',
        component: Sidebar,
        redirect: '/schoolBoardUser',
        meta: {
            modulesName: 'admin'
        },
        children: [{
                path: '/schoolBoardUser',
                component: schoolBoardUser,
                meta: {
                    title: '教育局用户',
                    icon: 'qq',
                },
            },
            {
                path: '/schoolUser',
                component: schoolUser,
                meta: {
                    title: '学校用户',
                    icon: 'qq',
                },
            },
            {
                path: '/schoolBoard',
                component: schoolBoard,
                meta: {
                    title: '教育局管理',
                    icon: 'qq',
                },
            },
            {
                path: '/loginLog',
                component: loginLog,
                meta: {
                    title: '登陆日志',
                    icon: 'qq',
                },
            }
        ]
    },
    // 教育局端
    {
        path: '/',
        component: Sidebar,
        redirect: '/Home',
        meta: {
            modulesName: 'jyj'
        },
        children: [{
            path: '/Home',
            component: Home,
            meta: {
                title: '教育局主页',
                icon: 'wx'
            },
        }]
    },
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: constRoutes
})

export default router